﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AISservice.Common
{
    public class PredicateAdapter<T>
    {
        private T _rParam;

        public T RParam
        {
            get { return _rParam; }
            set { _rParam = value; }
        }

        IEqualityComparer<T> _comparer;

        public PredicateAdapter(T obj)
        {
            _rParam = obj;
            _comparer = null;
        }

        public PredicateAdapter(T obj, IEqualityComparer<T> comparer)
        {
            _rParam = obj;
            _comparer = comparer;
        }

        public bool Predicate(T lParam)
        {
            if (_comparer != null)
                return _comparer.Equals(lParam, RParam);
            else
                return lParam.Equals(RParam);
        }
    }
}
